/*
 * lab1.fx
 *
 * Created on 13.09.2009, 0:41:20
 */
//in memories! epic win
package javafx179labs.nez.lab1;

/**
 * @author civil
 */


import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.Group;
import javafx.scene.transform.*;
import javafx.scene.effect.*;


/**
 * @author civil
 */
//good!
function blick (x: Integer, y: Integer) {

    Group {
            content: [
                    Ellipse {
                        centerX: x - 6
                        centerY: y + 13
                        radiusX: 7
                        radiusY: 13
                        fill: Color.WHITE
                        stroke: Color.BLACK
                    },

                    Ellipse {
                        centerX: x + 5
                        centerY: y + 60
                        radiusX: 4
                        radiusY: 4
                        fill: Color.WHITE
                        stroke: Color.BLACK
                    },

            ]
    }

}

//exellent
function eye (x: Integer, y: Integer) {

    Group {
            effect: Bloom {}
            content: [

                    Ellipse {
                        centerX: x
                        centerY: y + 30
                        radiusX: 16
                        radiusY: 40
                        //fill: Color.AQUA
                        fill: RadialGradient {
                            centerX: x
                            centerY: y + 30
                            radius: 90
                            focusX: x - 10
                            focusY: y + 16
                            proportional: false
                            stops: [
                                Stop {offset: 0 color: Color.AQUA},
                                Stop {offset: 1 color: Color.BLACK}
                            ]
                        }

                        stroke: Color.BLACK
                    },

                    Ellipse {
                        centerX: x
                        centerY: y + 30
                        radiusX: 10
                        radiusY: 30
                        stroke: Color.WHITE
                        fill: Color.BLACK
                    },

                    Path {
                        elements: [
                                MoveTo {
                                    x: x + 30
                                    y: y - 4
                                }

                                ArcTo {
                                    x: x
                                    y: y - 12
                                    radiusX: 40
                                    radiusY: 40
                                }

                                ArcTo {
                                    x: x - 36
                                    y: y + 5
                                    radiusX: 60
                                    radiusY: 60
                                }

                        ]
                    }

            ]

    }

}

//outstanding
function rotate (obgs: Group[], angl: Integer, x: Integer, y: Integer) {

    Group {
            transforms: [
                    Rotate {
                        angle: angl
                        pivotX: x
                        pivotY: y
                    }

            ]
            content: obgs
    }

}

function foo (privotX: Integer, privotY: Integer, x: Integer, y: Integer) {

    for (elem in [30..360][n | n mod 30 == 0]) {
            rotate([eye(x, y), blick(x, y)], elem, privotX, privotY)
    }

}

Stage {
    title: "Ня! ^__^"
    width: 624
    height: 570
    scene: Scene {
        fill: Color.GRAY

        content: [

            Group {
                effect: Reflection {
                    fraction: 0.5
                }

                content: [
                        Circle {
                            effect: Bloom {}
                            centerX: 200
                            centerY: 200
                            radius: 97
                            fill: LinearGradient {
                                stops: [
                                      Stop {offset: 0.0 color: Color.TURQUOISE},
                                      Stop {offset: 1.0 color: Color.BLUE},
                                ]

                            }

                            stroke: Color.BLACK

                        },

                        Group {
                                effect: DropShadow {
                                offsetX: 3
                                offsetY: 2.5
                                color: Color.BLACK
                            }

                            content: [
                                    foo(200, 200, 300, 100),
                                    foo(200, 200, 100, 100),
                            ]

                        },

                        Group {
                            effect: DropShadow {
                                offsetX: 3
                                offsetY: 2.5
                                color: Color.BLACK
                            }

                            content: [
                                    foo(200, 300, 200, 300)
                            ]
                        }


                ]
            },

            Group {
                content: [
                        Rectangle {
                            effect: DropShadow {
                                offsetY: 2.5
                                offsetX: 3
                                color: Color.BLACK
                            }

                            x: 400
                            y: 100
                            height: 50
                            width: 200
                            arcHeight: 20
                            arcWidth: 20
                            fill: LinearGradient {
                                stops: [
                                      Stop {offset: 0.0 color: Color.SILVER},
                                      Stop {offset: 1.0 color: Color.GRAY},
                                ]
                            }

                        },

                        Text {
                            x: 410
                            y: 130
                            font: Font {
                                size: 20
                            }

                            fill: Color.BLACK

                            content: "Ну как-то так -_-'"

                        }


                ]
            }

        ]
    }
}